/*
 * TownValidatorTests.cpp
 *
 *  Created on: 01 Ιουν 2010
 *      Author: Sartios
 */

#include "TownValidatorTests.h"

#include "../../../Validators/AddressValidators/TownValidators/TownValidator.h"

void TownValidatorTests::setUp(){
	townValidator_ = new TownValidator(8);
}

void	TownValidatorTests::tearDown(){
	delete townValidator_;
	townValidator_=NULL;
}

void	TownValidatorTests::townNameHasAppropriateLength_LengthSmallerThanMinWordLength_ReturnFalse(){
	string *town = new string;
	for(int i=0;i<townValidator_->getAppropriateTownNameLength();i++){
		*town+="a";
	}
	bool result = townValidator_->townNameHasAppropriateLength(town);
	delete town;
	CPPUNIT_ASSERT_MESSAGE("Town with less than minimum appropriate number shouldn't be appropriate",false==result);
}

void	TownValidatorTests::townNameHasAppropriateLength_LengthBiggerThanMinWordLength_ReturnTrue(){
	string *town = new string;
	for(int i=0;i<(townValidator_->getAppropriateTownNameLength()+1);i++){
		*town+="a";
	}
	bool result = townValidator_->townNameHasAppropriateLength(town);
	delete town;
	CPPUNIT_ASSERT_MESSAGE("Town with more than minimum appropriate number should be appropriate",true==result);
}

void	TownValidatorTests::townNameContainsValidContent_ContentHasOnlyChars_ReturnTrue(){
	string *town = new string("Serres");
	bool result = townValidator_->townNameContainsValidContent(town);
	CPPUNIT_ASSERT_MESSAGE("Name only with letters is a valid name",true==result);
}

void	TownValidatorTests::townNameContainsValidContent_ContentHasLetters_ReturnFalse(){
	string *town = new string("0123456789Serres");
	bool result = townValidator_->townNameContainsValidContent(town);
	CPPUNIT_ASSERT_MESSAGE("Name with numbers isn't a valid name",false==result);
}

void	TownValidatorTests::townNameContainsValidContent_ContentHasSymbols_ReturnFalse(){
	string *town = new string("0123456789Serres");
	const string *symbols_=new string("!@#$%^&*\\\"\(\(\',.?/;:}]{[|+=_-~`");
	*town+=*symbols_;
	bool result = townValidator_->townNameContainsValidContent(town);
	CPPUNIT_ASSERT_MESSAGE("Name with symbols isn't a valid name",false==result);
}
